﻿using System.ComponentModel;
using System.Windows.Forms;
using Dictionary.ERP;
using Extra.ERP;
using Common.Class;
using System.Drawing;

namespace Dictionary
{
    public class xfmDepartment : Form
    {
        public delegate void ItemSelectedEventHander(object sender, HRM_DEPARTMENT item);

        private readonly IContainer components;
        private bool _search;
        private xucDepartment xucdepartment;

        public xfmDepartment()
        {
            _search = false;
            components = null;
            InitializeComponent();
            Init();
        }

        public xfmDepartment(bool search)
        {
            _search = false;
            components = null;
            _search = search;
            InitializeComponent();
            Init();
        }

        public bool IsSearch
        {
            set { xucdepartment.IsSearch = value; }
        }

        public event ItemSelectedEventHander ItemSelected;

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Init()
        {
            SYS_LOG.Insert("Danh S\x00e1ch Ph\x00f2ng Ban", "Xem");
            xucdepartment = new xucDepartment();
            base.Controls.Add(xucdepartment);
            xucdepartment.Dock = DockStyle.Fill;
            xucdepartment.CloseClick += new ButtonClickEventHander(xucdepartment_CloseClick);
            Text = (SysOption.Language == "EN") ? "Department" : Text;
        }

        private void InitializeComponent()
        {
            base.SuspendLayout();
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x124, 0x10a);
            base.Name = "xfmDepartment";
            Text = "Ph\x00f2ng Ban";
            base.ResumeLayout(false);
        }

        private void RaiseItemSelectedEventHander(HRM_DEPARTMENT item)
        {
            if (ItemSelected != null)
            {
                ItemSelected(this, item);
            }
        }

        private void xucdepartment_CloseClick(object sender)
        {
            base.Close();
        }
    }
}